package com.anyou.mall.goo.goodsSpecs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.goodsSpecs.domain.GooGoodsSpecsValue;
import com.anyou.mall.goo.goodsSpecs.service.IGooGoodsSpecsValueService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 商品规格值Controller
 *
 * @author ylj
 * @date 2022-03-29
 */
@Api(tags = "商品规格值")
@RestController
@RequestMapping("/goodsSpecs/goodsSpecsValue")
public class GooGoodsSpecsValueController extends BaseController
{
    @Autowired
    private IGooGoodsSpecsValueService gooGoodsSpecsValueService;

    /**
     * 查询商品规格值列表
     */
    @ApiOperation("查询商品规格值列表")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:list')")
    @GetMapping("/list")
    public TableDataInfo<List<GooGoodsSpecsValue>> list(GooGoodsSpecsValue gooGoodsSpecsValue)
    {
        startPage();
        List<GooGoodsSpecsValue> list = gooGoodsSpecsValueService.selectGooGoodsSpecsValueList(gooGoodsSpecsValue);
        return getDataTable(list);
    }

    /**
     * 导出商品规格值列表
     */
    @ApiOperation("导出商品规格值列表")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:export')")
    @Log(title = "商品规格值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GooGoodsSpecsValue gooGoodsSpecsValue)
    {
        List<GooGoodsSpecsValue> list = gooGoodsSpecsValueService.selectGooGoodsSpecsValueList(gooGoodsSpecsValue);
        ExcelUtil<GooGoodsSpecsValue> util = new ExcelUtil<GooGoodsSpecsValue>(GooGoodsSpecsValue.class);
        util.exportExcel(response, list, "商品规格值数据");
    }

    /**
     * 获取商品规格值详细信息
     */
    @ApiOperation("获取商品规格值详细信息")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:query')")
    @GetMapping(value = "/{goodsSpecsValueId}")
    public ApiResult<GooGoodsSpecsValue> getInfo(@PathVariable("goodsSpecsValueId") Long goodsSpecsValueId)
    {
        return ApiResult.success(gooGoodsSpecsValueService.selectGooGoodsSpecsValueByGoodsSpecsValueId(goodsSpecsValueId));
    }

    /**
     * 新增商品规格值
     */
    @ApiOperation("新增商品规格值")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:add')")
    @Log(title = "商品规格值", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody GooGoodsSpecsValue gooGoodsSpecsValue)
    {
        return ApiResult.success(gooGoodsSpecsValueService.insertGooGoodsSpecsValue(gooGoodsSpecsValue));
    }

    /**
     * 修改商品规格值
     */
    @ApiOperation("修改商品规格值")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:edit')")
    @Log(title = "商品规格值", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody GooGoodsSpecsValue gooGoodsSpecsValue)
    {
        return ApiResult.success(gooGoodsSpecsValueService.updateGooGoodsSpecsValue(gooGoodsSpecsValue));
    }

    /**
     * 删除商品规格值
     */
    @ApiOperation("删除商品规格值")
    @PreAuthorize("@ss.hasPermi('goodsSpecs:goodsSpecsValue:remove')")
    @Log(title = "商品规格值", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsSpecsValueIds}")
    public ApiResult remove(@PathVariable Long[] goodsSpecsValueIds)
    {
        return ApiResult.success(gooGoodsSpecsValueService.deleteGooGoodsSpecsValueByGoodsSpecsValueIds(goodsSpecsValueIds));
    }
}
